function Food(el) {
    this.el = el
    this.len = 20
    this.foodObj = null
    this.foodX = 0
    this.foodY = 0
}
Food.prototype.create = function () {
    //造一个食物div
    //宽度20高度20
    //设置食物颜色 绝对定位
    let divObj = document.createElement('div')
    divObj.style.width = this.len + 'px'
    divObj.style.height = this.len + 'px'
    divObj.style.background = 'red'
    divObj.style.position = 'absolute'
    divObj.innerText='食'
    // 保存食物对象，其他方法中要用到
    this.foodObj = divObj
    //追加到页面
    this.el.appendChild(divObj)
    this.move()
}
//食物只显示默认位置 要让他随机显示 此处创建move方法
Food.prototype.move = function () {
    // 产生随机数：X轴（0-39）*20  Y轴（0-19）*20
    let foodXMaxNum = this.el.clientWidth / this.len - 1
    let foodYMaxNum = this.el.clientHeight / this.len - 1
    this.foodX = Math.floor(Math.random() * (foodXMaxNum + 1)) * this.len
    this.foodY = Math.floor(Math.random() * (foodYMaxNum + 1)) * this.len
    this.foodObj.style.left = this.foodX + 'px'
    this.foodObj.style.top = this.foodY + 'px'
}